package org.hxyjs.controller;

import cn.hutool.db.Page;
import org.hxyjs.dto.DTO;
import org.hxyjs.entity.Activitytype;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.ActivitytypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller //@Controller注解是用spring容器生成 对象 默认对象名 activitytypeController
@RequestMapping("/activitytypeController") //@RequestMapping 用户请求查找该资源使用的名字 网名 默认  /activitytypeController
public class ActivitytypeController {
	@Resource
    ActivitytypeService activitytypeService;
	@RequestMapping("/getAllActivitytype")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Activitytype> getAllActivitytype() throws Exception{
    	System.out.println("查询活动类型");
    	return activitytypeService.getAllActivitytypes();
    }
	@RequestMapping("/addActivitytype")
	@ResponseBody
	public DTO<Activitytype> addActivitytype(@RequestBody Activitytype activitytype) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加活动类型成功");
		return activitytypeService.addActivitytype(activitytype);
	}



	@RequestMapping("/deleteActivitytypeByAtno/{atno}")
	@ResponseBody
    public DTO<Activitytype> deleteActivitytypeByAno(@PathVariable("atno") String atno) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(atno+"删除活动类型成功");
    	return activitytypeService.deleteActivitytypeByAtno(atno);
    }



	@RequestMapping("/getActivitytypeByAtno/{atno}")
	@ResponseBody
	public DTO<Activitytype> getActivitytypeByAno(@PathVariable("atno") String atno) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println(atno+"根据主键查询活动类型成功");
		return activitytypeService.getActivitytypeByAtno(atno);
	}

	@RequestMapping("/updateActivitytype")
	@ResponseBody
	public DTO<Activitytype> updateActivitytype(@RequestBody Activitytype activitytype) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改活动类型成功");
		return activitytypeService.updateActivitytype(activitytype);
	}
	@RequestMapping("/getActivitytypeByPage")
	@ResponseBody
	public DTO<Activitytype> getActivitytypeByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页类型成功");
		return activitytypeService.getActivitytypeByPage(pageInfo);
	}
}
